/***************************************************************************
 *   Copyright (C) 2007 by Eduardo Robles Elvira   *
 *   edulix@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <QAction>
#include <QIcon>
#include <QMenu>
#include <QModelIndex>
#include <QWidget>
#include <QDebug>
#include <QContextMenuEvent>
#include "conntracksview.h"

ConntracksView::ConntracksView(QWidget *widget) : QTreeView(widget)
{
	popup = new QMenu(widget);
	delAction = new QAction(QIcon("delete-selection"),  tr("Delete selected"), this);
	connect(delAction, SIGNAL(triggered()), this, SIGNAL(removeSelection()));
	popup->addAction(delAction);
	
	qDebug() << "1" << endl;
}

void ConntracksView::contextMenuEvent(QContextMenuEvent * event)
{
	const QModelIndex index = indexAt(event->pos());
	
	if (!index.isValid()) {
		// only open a context menu above an item
		return;
	}
	popup->exec(event->globalPos());
}

